//
//  GMNewFeatureViewController.m
//  goldmetal
//
//  Created by mac on 2017/1/22.
//  Copyright © 2017年 宏鹿. All rights reserved.
//


#define IWNewfeatureImageCount 3

#import "GMNewFeatureViewController.h"

#import "BaseTabbarController.h"
#import "BaseNavigationController.h"


@interface GMNewFeatureViewController ()<UIScrollViewDelegate>

@end


@implementation GMNewFeatureViewController


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self setupScrollView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)setupScrollView{
    
    UIScrollView * scrollView = [[UIScrollView alloc]init];
    scrollView.frame = self.view.bounds;
    scrollView.delegate = self;
    [self.view addSubview:scrollView];
    
    //添加图片
    for (int i = 0; i < IWNewfeatureImageCount; i++) {
        UIImageView * imageView = [[UIImageView alloc]init];
        imageView.frame = CGRectMake(i * scrollView.frame.size.width, 0, scrollView.frame.size.width, scrollView.frame.size.height);
        NSString * name = [NSString stringWithFormat:@"yindaoye%d",i+1];
        imageView.image = [UIImage imageNamed:name];
        [scrollView addSubview:imageView];
        
        if (i == IWNewfeatureImageCount - 1) {
            [self setupLastImageView:imageView];
        }
        
    }
    
    scrollView.contentSize = CGSizeMake(IWNewfeatureImageCount * scrollView.frame.size.width, scrollView.frame.size.height);
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.pagingEnabled = YES;
    scrollView.bounces = NO;
}


///添加最后一页的内容等
- (void)setupLastImageView:(UIImageView *)imageView{
    
    imageView.userInteractionEnabled = YES;
    
    UIButton * startButton = [[UIButton alloc]init];
    
    //设置尺寸
    startButton.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    
    [startButton setBackgroundColor:[UIColor clearColor]];
    
    [startButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [startButton addTarget:self action:@selector(startButton) forControlEvents:UIControlEventTouchUpInside];
    [imageView addSubview:startButton];
    
}

///点击开始按钮
-(void)startButton{
    BaseTabbarController *root = [[BaseTabbarController alloc]init];
    self.view.window.rootViewController = root;
}





@end
